package com.aitou.mrylive.presentation.ui.main.find;

import com.aitou.mrylive.data.bean.BaseResponse;
import com.aitou.mrylive.presentation.ui.base.BaseObserver;
import com.aitou.mrylive.presentation.ui.base.BasePresenter;
import com.aitou.mrylive.presentation.ui.main.find.pengyouquan.MeiLiBangBean;

import java.util.List;

import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by admin on 2016/9/20.
 */
public class PaiHangBangPresenter extends BasePresenter<MeiLiBangInterFace> {
    private MeiLiBangManager meiLiBangManager;
    public PaiHangBangPresenter(MeiLiBangInterFace uiInterface) {
        super(uiInterface);
        meiLiBangManager = new MeiLiBangManager();
    }

    public void getMeiLiBang(int type){
        Subscription subscription = meiLiBangManager.meiLiList(type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<BaseResponse<List<MeiLiBangBean>>>(getUiInterface()) {
                    @Override
                    public void onSuccess(BaseResponse<List<MeiLiBangBean>> response) {

                        getUiInterface().showResult(response.getData());
//                        List<MeiLiBangBean> list = response;
//                        if (list==null ){
//                            getUiInterface().showEmptyResult();
//                        }
//                        else {
//                            getUiInterface().showData(list);
//                        }
                    }
                });
        addSubscription(subscription);
    }
    public void getFuBang(int type){
        Subscription subscription = meiLiBangManager.meiLiList(type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<BaseResponse<List<MeiLiBangBean>>>(getUiInterface()) {
                    @Override
                    public void onSuccess(BaseResponse<List<MeiLiBangBean>> response) {
                        getUiInterface().showResult(response.getData());
                    }
                });
        addSubscription(subscription);
    }
    public void getFuHaoBang(int type){
        Subscription subscription = meiLiBangManager.fuHaoList(type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<BaseResponse<List<MeiLiBangBean>>>(getUiInterface()) {
                    @Override
                    public void onSuccess(BaseResponse<List<MeiLiBangBean>> response) {
                        getUiInterface().showResult(response.getData());
                    }
                });
        addSubscription(subscription);
    }
}
